<?php
    /**
     * Created by PhpStorm.
     * User: huangzhongwei
     * Date: 2018/10/24
     * Time: 9:13
     */

    namespace app\common\model;


    use think\Model;
    use app\lib\exception\MissException;

    class University extends Model
    {
        protected $table = "university";
        protected $autoWriteTimestamp = true;

        public static function isExisted($id)
        {
            $university = self::where('id', $id)->find();
            if (!$university) {
                throw new MissException(['msg' => '当前大学不存在', 'errorCode' => '20000']);
            }
            return $university;
        }


        public function goodsType(){
            return $this->hasMany('GoodsType','university_id');
        }

        public function order(){
            return $this->hasMany('Order','university_id');
        }

        public function orderHasVoucher(){
            return $this->hasMany('Order','university_id');
        }

    }